Row

Chart 1

Chart 2

Row

Chart 3

Chart 4

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    source: embed
---
 
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(dplyr)
library(plotly)
library(p8105.datasets)
```


```{r}
data("rest_inspec") 

rest_inspec2 =
  rest_inspec %>%
  select(boro, cuisine_description, dba, zipcode, violation_code, violation_description, grade, grade_date, critical_flag, score) %>%
mutate(zipcode = as.character(zipcode)) %>%
filter(!is.na(grade),!is.na(violation_description), !is.na(score)) %>%
filter(boro == "STATEN ISLAND", 
       !grade == "Not Yet Graded", 
       !grade == "P", 
       !grade == "Z")  

```
   
Row
-------------------------------------
    
### Chart 1
    
```{r}
#Number of restaurants per grade (Bar Graph) 
rest_inspec2 %>% 
  count(grade) %>% 
  mutate(grade = fct_reorder(grade, n)) %>% 
  plot_ly(x = ~grade , y = ~n, color = ~grade,
          type = "bar", colors = "viridis") %>% 
  layout(title = 'Number of Restaurants in Staten Island per Letter Grade',
         yaxis = list(title = "Number of Restaurants"),
         xaxis = list(title =  "Letter Grade")
         )
```
   
    
### Chart 2
    
```{r}
#ZIPCODE VS CUISINE (scatter)
rest_inspec2 %>% 
plot_ly(
    x = ~zipcode, y = ~cuisine_description, 
    type = "scatter", text = ~dba,
    mode = "markers",
    color = ~grade, alpha = 0.5) %>% 
  layout(title = 'Types of Cuisine Located in Each Staten Island Zip Code',
         yaxis = list(title = "Type of Cuisine"),
         xaxis = list(title =  "Zip Code")
         )
```

Row
-------------------------------------

### Chart 3

```{r}
#GRADE VS SCORE (box)
rest_inspec2 %>% 
  plot_ly(x = ~grade, y = ~score, color = ~grade, type = "box", colors = "viridis") %>% 
  layout(title = 'Distribution of Scores per Grade of Staten Island Resturants',
         yaxis = list(title = "Score"),
         xaxis = list(title =  "Letter Grade")
         )
```

### Chart 4

```{r}
#ZIPCODE VS SCORE
rest_inspec2 %>% 
  plot_ly(x = ~zipcode, y = ~score, color = ~grade, type = "scatter",
          text = ~dba, mode = "markers", colors = "viridis") %>% 
  layout(title = 'Scores of Staten Island Restuarnts by Zip Codes',
         yaxis = list(title = "Score"),
         xaxis = list(title =  "Zip Code")
         )
```